package com.anlu.base.map;
import java.util.*;
public class TreeMapTest {


        public static void main(String[] args) {
            TreeMap<String, String> treeMap = new TreeMap<>();
            treeMap.put("apple", "fruit");
            treeMap.put("application", "software");
            treeMap.put("applet", "small application");
            treeMap.put("banana", "fruit");
            treeMap.put("orange", "fruit");

            // 查找以"app"开头的所有key
            String prefix = "app";
            SortedMap<String, String> result = treeMap.subMap(prefix, prefix + Character.MAX_VALUE);



            System.out.println("Keys starting with '" + prefix + "':");
            for (Map.Entry<String, String> entry : result.entrySet()) {
                System.out.println(entry.getKey() + " -> " + entry.getValue());
            }
        }
}
